//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.Provenance.Controls.View
{
    using System.Windows.Controls;
    using Microsoft.Research.Provenance.Controls.Presenter;

    /// <summary>
    /// Interaction logic for WorkFlowSummaryView.xaml
    /// </summary>
    public partial class WorkflowSummaryView : UserControl
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public WorkflowSummaryView()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the WorkFlowSummaryPresenter Model to the view's data context.
        /// </summary>
        public WorkflowSummaryPresenter Presenter
        {
            get { return this.DataContext as WorkflowSummaryPresenter; }
            set { this.DataContext = value; }
        }

        /// <summary>
        /// The event handler for expanded control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">RoutedEventArgs.</param>
        private void OnExpanded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (!Presenter.IsUpdated)
            {
                Presenter.GetWorkflowSummary.Execute(null);
            }
        }
    }
}
